// 示例 1：

// 输入：path = "/home/"

// 输出："/home"

// 解释：

// 应删除尾随斜杠。

path = "/home/user/Documents/../Pictures"

var simplifyPath = function (path) {
    let names = path.split('/')
    let stack = []
    for (let name of names) {
        if (name === '..') {
            if (stack.length) {
                stack.pop()
            }
        } else if (name.length && name !== '.') {
            stack.push(name)
        }
    }

    return '/' + stack.join('/');
};

console.log(simplifyPath(path));
